﻿using System;
using MVVM.Northwind.Employee.Services;
using System.ComponentModel;

namespace MVVM.Northwind.Employee.ViewModel
{
    public abstract class ViewModelBase:INotifyPropertyChanged, IDisposable
    {

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string PropertyName)
        {
            var e = new PropertyChangedEventArgs(PropertyName);
            PropertyChanged(this, e);
        }

        public string DisplayName { get; set; }
        
        public void Dispose()
        {
            OnDispose();
        }

        public TServiceContract GetService<TServiceContract>()
            where TServiceContract : class
        {
            return ServiceContainer.Instance.GetService<TServiceContract>();
        }
        protected virtual void OnDispose() {}
    }
}
